<template>
    <div class="wai">
        <div>
            <input type="text" placeholder="账户名/手机号/Email" v-model="text">
        </div>
        <div>
             <input type="password" placeholder="请输入您的密码" v-model="password">
        </div>
        <button @click="fun()">登录</button>
    </div>
</template>

<script>
import { Toast } from "vant";

import postdata from "@/api/postdata";
export default {
  data() {
    return {
      text: "",
      password: ""
    };
  },
  methods: {
    fun() {
      // 如果你想发送post数据 需要修改数据发送的方式
      let usp = new URLSearchParams();
      usp.append("tel", this.text);
      usp.append("password", this.password);

      postdata("/apidl/login", usp).then(ok => {
        if (ok.data == this.text) {
          Toast.success("登陆成功");
          sessionStorage.setItem("login", "true");
          this.$router.push("/my");
        } else {
          Toast.fail("用户名或密码错误");
        }
      });
    }
  }
};
</script>

<style scoped>
.wai {
  background-color: rgb(244, 244, 244);
}
.wai > div {
  width: 100%;
  background-color: white;
  border-bottom: 1px solid rgb(220, 220, 220);
}
input {
  width: 90%;
  height: 0.58rem;
  border-radius: 0.06rem;
  margin: 0.15rem auto;
  background-color: rgb(236, 236, 236);
  font: inherit;
  font-family: inherit;
  padding: 0 0.15rem;
}
button {
  width: 94%;
  height: 0.6rem;
  margin-top: 0.27rem;
  line-height: 0.6rem;
  border: none;
  color: white;
  background-color: rgb(223, 45, 45);
  font-size: 0.28rem;
  border-radius: 0.1rem;
}
</style>
